
#include "sid.d2"
  
def sid_tick:byte
def sid_speed:byte
def sid_ptr:word

#const g1 = 822		// E3
#const b1 = 1097	// E7
#const d2 = 1305	// A5
#const fx2 = 1644	// A9
#const a2 = 1845	// D7
#const b2 = 2071	// D9

// Guns of Brixton
def notes:word[] = \
  b1,  0, b1,  0, b1, 0, d2, 0,fx2,fx2,fx2,fx2,fx2, 0, d2,  0, b1,  0, b1,  0, b1, 0, d2, 0,fx2,fx2,fx2,fx2,fx2, 0, d2, 0, \
  b1,  0, b1,  0, b1, 0, d2, 0,fx2,fx2,fx2,fx2,fx2, 0, d2,  0, b1,  0, b1,  0, b1, 0, d2, 0,fx2,fx2,fx2,fx2,fx2, 0, d2, 0, \
 fx2,fx2,fx2,fx2,fx2, 0, a2, 0, b2,  0, b1,  0, d2, 0,fx2,fx2,fx2,fx2,fx2,  0, a2, 0, b2, 0, b1,  0, d2,  0, \
  g1, g1, g1, g1, g1, 0, d2, 0, b1,  0, b1,  0, b1, 0, d2,  0, g1, g1, g1, g1, g1, 0, d2, 0,  1 
				        
sub init_musique() {
	sid_tick = 0
	sid_ptr = 0
	sid_speed = 5
}


sub sid_play_music() {
	inc sid_tick
	if(sid_tick > sid_speed) {
		sid_tick = 0

		sid_control = 0

sid_again:
		def freq:word
		freq = notes[sid_ptr]

		if(freq = 1) {
			sid_ptr = 0
			goto sid_again
		}
		if(freq = 0) {
			inc sid_ptr
			return
		}
		// Spela ton
		sid_filtermode_volume = 6
		sid_attack_decay = 6
		sid_sustain_release = 0
		sid_freq = freq
		sid_control = 33

		inc sid_ptr
	}
}


